Skip to content

TRUNK-5881: Order Domain - Switching from Hibernate Mappings to Annotations #4996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ajeyprasand
Copy link

@ajeyprasand ajeyprasand commented Apr 5, 2025

TRUNK-5881: Order Domain - Switching from Hibernate Mappings to Annotations

Description of what I changed

Modified Order.java
Added java annotations by referring Order.hbm.xml

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-5881

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@ajeyprasand ajeyprasand changed the title added java annotations by referring Order.hbm.xml TRUNK-5881: Order Domain - Switching from Hibernate Mappings to Annotations Apr 5, 2025
Copy link
Contributor

@ManojLL ManojLL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajeyprasand Thanks for the PR, this implantation is not completed you have to remove existing xml mapping and update test.
please refer this PRs: 335c2b5

b2bd587

@ajeyprasand
Copy link
Author

@ManojLL I have updated the changes as requested. Do check and share your feedback

@ManojLL
Copy link
Contributor

ManojLL commented Apr 11, 2025

@ajeyprasand some changes are not directly related to the scope of this JIRA ticket TRUNK-5881. when creating a PR that should focus only about related changes, in this case DrugOrder, ReferalOrder.. entities are having separate tickets. you can open separate PRs for those.

@ajeyprasand
Copy link
Author

ajeyprasand commented Apr 11, 2025

is it out of order domain? but in the order hibernate xml file, it had configurations for drug order, referral order, test order. and I cant find tickets for these too. @ManojLL

Copy link

@rishabhrawat05 rishabhrawat05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to create annotations for the Order Domain only and keep the rest as it is. These changes should include creating annotations for the Order Domain, deleting the Order hibernate config file, removing the hibernate mapping, and adding a test for the Order Domain.

@ajeyprasand
Copy link
Author

Oh, okay. I got a bit confused because there was no hibernate xml file for DrugOrder, etc and the hibernate xml file for Order had the configurations for them. So, I initially thought that deleting the Order XML file might result in data loss, which is why I went ahead and added Hibernate annotations for them. But now, I've removed those annotations. Please take a look and let me know @rishabhrawat05 @ManojLL

@@ -58,7 +58,7 @@ public void setUp() throws Exception {
o = new Order();
}


Copy link

@rishabhrawat05 rishabhrawat05 Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all the changes from this file

@@ -60,6 +60,7 @@
import org.openmrs.ProgramAttributeType;
import org.openmrs.Provider;
import org.openmrs.ProviderAttributeType;
import org.openmrs.ReferralOrder;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this import statement of ReferralOrder

@@ -9,12 +9,15 @@
*/
package org.openmrs;

import javax.persistence.MappedSuperclass;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all the changes from this file

Copy link
Author

@ajeyprasand ajeyprasand Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabhrawat05 do I also have to add getter and setter for "attributes" of type Set which is a field newly added, and include it in copyHelper and cloneForRevision?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabhrawat05 do I also have to add getter and setter for "attributes" of type Set which is a field newly added, and include it in copyHelper and cloneForRevision?

No, I think there is no need for that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabhrawat05 okk. Do review the pr now.

Copy link

@rishabhrawat05 rishabhrawat05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManojLL can you review this

@ManojLL
Copy link
Contributor

ManojLL commented Apr 14, 2025

@ajeyprasand There is a build failure, could you please take a look?

@ajeyprasand
Copy link
Author

ajeyprasand commented Apr 15, 2025

@ManojLL @rishabhrawat05 According to the logs org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-service.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.openmrs.MedicationDispense.drugOrder references an unknown entity: org.openmrs.DrugOrder , in org.openmrs.MedicationDispense, there is an @many To One mapping in drugorder, but since drugOrder is not an entity its throwing an error. Drug order configuration was mentioned in the order hibernate xml file. Now since its deleted, its throwing the error.

@ajeyprasand
Copy link
Author

ajeyprasand commented Apr 18, 2025

@ManojLL @rishabhrawat05 but If I revert the changes to "added required changes" commit and modify a little more, its working fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants